home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_Tix.idb / usr / freeware / lib / tix4.1 / demos / samples / BtnBox.tcl.z / BtnBox.tcl
Encoding:
Text File  |  1999-01-26  |  1.8 KB  |  54 lines

  1. # Tix Demostration Program
  2. #
  3. # This sample program is structured in such a way so that it can be
  4. # executed from the Tix demo program "widget": it must have a
  5. # procedure called "RunSample". It should also have the "if" statment
  6. # at the end of this file so that it can be run as a standalone
  7. # program using tixwish.
  8.  
  9. # This file demonstrates the use of the tixButtonBox widget, which is a
  10. # group of TK buttons. You can use it to manage the buttons in a dialog box,
  11. # for example.
  12. #
  13. proc RunSample {w} {
  14.  
  15.     # Create the label on the top of the dialog box
  16.     #
  17.     label $w.top -padx 20 -pady 10 -border 1 -relief raised -anchor c -text \
  18.     "This dialog box is\n a demostration of the\n tixButtonBox widget"
  19.  
  20.     # Create the button box and add a few buttons in it. Set the
  21.     # -width of all the buttons to the same value so that they
  22.     # appear in the same size.
  23.     #
  24.     # Note that the -text, -underline, -command and -width options are all
  25.     # standard options of the button widgets.
  26.     #
  27.     tixButtonBox $w.box -orientation horizontal
  28.     $w.box add ok    -text OK    -underline 0 -command "destroy $w" -width 5
  29.     $w.box add close -text Close -underline 0 -command "destroy $w" -width 5
  30.  
  31.     pack $w.box -side bottom -fill x
  32.     pack $w.top -side top -fill both -expand yes
  33.  
  34.     # "after 0" is used so that the key bindings won't interfere with
  35.     # tkTraverseMenu
  36.     #
  37.     bind [winfo toplevel $w] <Alt-o>  \
  38.     "after 0 tkButtonInvoke [$w.box subwidget ok]"
  39.     bind [winfo toplevel $w] <Alt-c>  \
  40.     "after 0 tkButtonInvoke [$w.box subwidget close]"
  41.     bind [winfo toplevel $w] <Escape> \
  42.     "after 0 tkButtonInvoke [$w.box subwidget close]"
  43.  
  44.     focus [$w.box subwidget ok] 
  45. }
  46.  
  47. if {![info exists tix_demo_running]} {
  48.     wm withdraw .
  49.     set w .demo
  50.     toplevel $w
  51.     RunSample $w
  52.     bind $w <Destroy> exit
  53. }
  54.